package data.platform.common.merge;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter
@NoArgsConstructor
public class LoadPercentAggregateItem extends AggregateItem {

    private Integer lowCount = 0;

    private Integer midCount = 0;

    private Integer highCount = 0;

    private Integer count = 0;

    public LoadPercentAggregateItem(MergePeriod mergePeriod, MergeTimeWindow mergeTimeWindow) {
        super(mergePeriod, mergeTimeWindow);
    }

    @Override
    public void compute(Double value, LocalDateTime eventTime) {
        switch (value.intValue()) {
            case 0:
                lowCount++;
                break;
            case 1:
                midCount++;
                break;
            case 2:
                highCount++;
                break;
        }
        count++;

        dirty.compareAndSet(false, true);
    }
}
